import { request } from 'umi';
import type { CurrentUser, GeographicItemType } from './data';

export async function queryCurrent(options?: { [key: string]: any }) {
    return request('/api/ucUser/current', {
        method: 'POST',
        ...(options || {}),
    });
}
export async function getCode(params: UserRegisterParams) {
    return request('/api/sysUser/getVerifyCode', {
        method: 'POST',
        data: params,
    });
}
export async function updatePassword(params: any) {
    return request('/api/sysUser/updateById', {
        method: 'PUT',
        data: params,
    });
}

export async function updatePhone(params: UserRegisterParams) {
    return request('/api/sysUser/updateUserPhone', {
        method: 'POST',
        data: params,
    });
}

export async function queryProvince(): Promise<{ data: GeographicItemType[] }> {
    return request('/api/geographic/province');
}

export async function queryCity(province: string): Promise<{ data: GeographicItemType[] }> {
    return request(`/api/geographic/city/${province}`);
}

export async function query() {
    return request('/api/users');
}
